package Client;

import java.io.*;

public class CLI implements Runnable {
	private boolean loop;
	private BufferedReader in;
	private TrafficHandler handler;


	public CLI(TrafficHandler handler){
		this.handler = handler;
		this.loop = true; //aanpassen na een close?
		new Thread(this).run();
	}


	public String getInputString() throws IOException {
		return in.readLine();
	}

	@Override
	public void run() {
		String result = new String();
		in = new BufferedReader( new InputStreamReader( System.in ) );
		System.out.println("Ready for input: ");
		while (loop) {
			result = "";
			try{				
				result = getInputString();

				//resultaat moet naar een Socketclass oid
				if (!result.isEmpty())
					handler.InputFromCLI(result);

			} catch ( IOException ioe )	{
				ioe.printStackTrace();
			}
		}
	}

}


